/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package taglibs;

import daos.CardTypeDAO;
import daos.MemberDAO;
import java.util.ArrayList;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import models.CardType;
import models.Member;
import util.Common;
import util.WebConst;

/**
 *
 * @author trietto
 */
public class RegistrationForm extends TagSupport {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /*
     * (non-Javadoc)
     * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
     */
    public int doStartTag() {
        try {
            JspWriter writer = pageContext.getOut();
            ArrayList<String> lstCardTypeData = new ArrayList<String>();
            ArrayList<CardType> lstCardType = CardTypeDAO.singleton().selectAll();
            for (CardType cardType : lstCardType) {
                lstCardTypeData.add(cardType.getName() + "\t" + cardType.getCardTypeId());
            }

            writer.println("<form action='RegistrationServlet' method='POST'>");
            writer.println("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
            writer.println("<tr>");
            writer.println("<td colspan='2' align='center'><b>REGISTER NEW ACCOUNT</b><br></td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Username:</td>");
            writer.println("<td>" + Common.createTextbox("txtMemberLogin", "txtMemberLogin", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Password:</td>");
            writer.println("<td>" + Common.createPasswordField("txtMemberPassword", "txtMemberPassword", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Card Number:</td>");
            writer.println("<td>" + Common.createTextbox("txtCardNumber", "txtCardNumber", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Card Type:</td>");
            writer.println("<td>" + Common.createComboBox("cbCardType", "cbCardType", (String[]) (lstCardTypeData.toArray(new String[0])), "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>First Name:</td>");
            writer.println("<td>" + Common.createTextbox("txtFirstName", "txtFirstName", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Last Name:</td>");
            writer.println("<td>" + Common.createTextbox("txtLastName", "txtLastName", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Phone:</td>");
            writer.println("<td>" + Common.createTextbox("txtPhone", "txtPhone", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Address:</td>");
            writer.println("<td>" + Common.createTextbox("txtAddress", "txtAddress", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Email:</td>");
            writer.println("<td>" + Common.createTextbox("txtEmail", "txtEmail", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr>");
            writer.println("<td>Notes:</td>");
            writer.println("<td>" + Common.createTextbox("txtNotes", "txtNotes", "", "", "") + "</td>");
            writer.println("</tr>");
            writer.println("<tr colspan='2'>");
            writer.println("<td>" + Common.createSubmitButton("btnRegister", "btnRegister", "Register", "") + "</td>");
            writer.println("</tr>");
            writer.println("</table>");
            writer.println("</form>");

        } catch (Exception e) {
        }
        return SKIP_BODY;
    }
}
